/****************************************************************************
**
** Copyright (C) 2009 Alexander Solis.
**
** This file is part of Alejandria
** Alejandria is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Alejandria is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Alejandria.  If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/

#include <QApplication>
#include <QObject>
#include <QTableView>

#include "model/library.h"
#include "view/mainwindow/MainWindow.h"

int main(int argc, char *argv[])
{
    #ifdef _WINDOWS
        #ifdef _DEBUG
            __debugbreak(); // We launch Visual Studio for debugging Alejandria at the beginning
        #endif
    #endif

	QApplication app(argc, argv);
    MainWindow *MWin;
    MWin = 0;

    //The windows path for plugins is in the root folder
    //where the .exe is located 
    #ifdef _WINDOWS
        app.addLibraryPath(".");
    #endif

    //Create the Model
	Library lib;
    if (lib.connectToDB()) {	
    	//Create the View and Link the View and Model
    	MWin = new MainWindow(0, lib);
    }

    int ret = app.exec();

    // Free the allocated memory for the Main Window
    delete MWin;
    MWin = 0;

    return ret;
};
